package org.achao.rabbitmq;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

/**
 * @author achao
 * @description mq连接创建封装
 * @date 2023/10/25 23:49
 */
public class RabbitMqUtil {

    /**
     * 得到一个连接的 channel
     * @return
     * @throws Exception
     */
    public static Channel getChannel() throws Exception{
        //创建一个连接工厂
        ConnectionFactory connectionFactory = new ConnectionFactory();
        connectionFactory.setHost("121.37.241.70");
        connectionFactory.setUsername("achao");
        connectionFactory.setPassword("125614");
        Connection connection = connectionFactory.newConnection();
        return connection.createChannel();
    }
}
